<?php

class Model_HmArticleCategoryDescr extends Zend_Db_Table_Abstract
{
	protected $_name = 'hm_article_category_descr';
	protected $_primary = 'id';
	protected $_sequence = true;
	protected $_dependentTables = 'Model_HmArticleCategory';
	
	public function getAll()
	{
		$row = $this->fetchAll();
		if(!$row) {
			throw new Exception('Could not fetch records.');
		}
		return $row->toArray();
	}
	
	public function getRow($id)
	{
		$row = $this->fetchRow('id = '.(int)$id);
		if(!$row) {
			throw new Exception('Could not fetch row $id');
		}
		return $row->toArray();
	}
	
	public function addRow($data)
	{
		$row = $this->createRow($data);
		$row->save();
	}
	
	public function updateRow($id, $data)
	{
		$where = 'id = '.(int)$id;
		$row = $this->update($data, $where);
		if(!$row) {
			throw new Exception('Could not update row '.(int)$id);
		}
		return true;
	}
	
	public function deleteRow($id)
	{
		$where = 'id = '.(int)$id;
		$row = $this->delete($where);
		if(!$row) {
			throw new Exception('Could not delete row '.(int)$id);
		}
		return true;
	}
}